<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.util.*"%>
    <%@page import="java.sql.*" %>
    <jsp:useBean id="dbcon" class="com.bean.ywj.DBcon01" scope="request"/>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录检查</title>
</head>
<body>
	<%
	String username=new String(request.getParameter("username"));  
    String password=new String(request.getParameter("pwd")); 
    request.getSession().setAttribute("username", username);
    request.getSession().setAttribute("password", password);
    try{
    	
    	Connection conn=dbcon.getConnection();
	   if( conn != null){         
            String sql="select * from login where username='"+username+"' and password='"+ password + "'";  
            Statement stmt =  conn.createStatement();  
            ResultSet rs=stmt.executeQuery(sql);  
            if(rs.next()){  
            response.sendRedirect("main.jsp");    
           }else{
          
                out.print("用户名或密码错误，请重新输入！"); 
                %>
                <a href="javascript:history.back()">返回</a>  
            <%    
            } 
        rs.close();
		stmt.close();
		conn.close();
               
    } else{  
            // 输出连接信息  
            out.println("数据库连接失败！");                          
        }
        
    }catch (SQLException e) {  
        e.printStackTrace();  
    }  
%>
</body>
</html>